﻿using System.Collections.Generic;
using MvcContrib;
using Tamias.BasicCmsPortableArea.Messages;

namespace Tamias.BasicCmsPortableArea.Domain
{
    public class ContentGroupService : IContentGroupService
    {
        public ContentGroup Get(int groupId)
        {
            var message = new GetGroupMessage();
            message.GroupId = groupId;
            Bus.Send(message);
            return message.Group;
        }

        public List<ContentGroup> GetGroups()
        {
            var message = new GetGroupsMessage();
            Bus.Send(message);
            return message.Groups;
        }

        public void Save(ContentGroup group)
        {
            var message = new SaveContentGroupMessage();
            message.Group = group;
            Bus.Send(message);
        }

        public void Delete(int id)
        {
            var message = new DeleteContentGroupMessage();
            message.ContentGroupId = id;
            Bus.Send(message);
        }
    }
}
